package com.scedu.reflection;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Data
@AllArgsConstructor
@NoArgsConstructor
@TableName(value = "tablesc")
public class Student2 {
    @fieldAnnotation(columnName="tb_id",type = "int",length = 10)
    private Integer id;
    @fieldAnnotation(columnName="tb_age",type = "int",length = 10)
    private Integer age;
    @fieldAnnotation(columnName="tb_name",type = "varchar",length = 10)
    private String name;
}

//自定义一个类名的注解
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@interface TableName{
    String value();
}

//定义一个属性的注解
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@interface fieldAnnotation{
    String columnName(); //列名
    String type();//类型
    int length();//字段长度

}